/**
 * @file main.c
 * @author Nations
 * @version V1.2.2
 *
 * @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
 */
#include "main.h"
#include <stdio.h>
#include <stdint.h>
#include "my_gpio.h"
#include "sys_param.h"
#include "zhan_zhi_dao.h"

static int zhan_online_cnt = 0;
static int zhan_offline_cnt = 0;

/*100ms扫描一次*/
void my_zhanzhidao_scanf(void)
{
    if(IS_ZHANZHIDAO_ONLINE())  
    {
        zhan_online_cnt ++;
        if(zhan_online_cnt > 10){
            zhan_offline_cnt = 0;
            if(OFF_LINE == get_zhan_zhi_dao_state()){
                set_zhan_zhi_dao_state(ON_LINE);

                // motor_shor_on();
            }
        }
    }
    else{
        zhan_offline_cnt ++;
        if(zhan_offline_cnt > 10){
            zhan_offline_cnt = 0;
            set_zhan_zhi_dao_state(OFF_LINE);
        }    
    }
}

void my_zhanzhidao_init(void)
{

    gpio_input_cfg(ZHANZHIDAO_IN_PORT, ZHANZHIDAO_IN_PIN, GPIO_Pull_Down);
}
